package com.social.serviceImpl;

import com.social.dao.PostMapper;
import com.social.pojo.Post;
import com.social.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class PostServiceImpl implements PostService {
    @Autowired
    private PostMapper postMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        int status = postMapper.deleteByPrimaryKey(id);
        return status;
    }

    @Override
    public int insert(Post record) {
        int status = postMapper.insert(record);
        return status;
    }

    @Override
    public int insertSelective(Post record) {
        int status = postMapper.insertSelective(record);
        return status;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public Post selectByPrimaryKey(Integer id) {
        Post post = postMapper.selectByPrimaryKey(id);
        return post;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<Post> selectAll() {
        List<Post> posts = postMapper.selectAll();
        return posts;
    }

    @Override
    public int updateByPrimaryKeySelective(Post record) {
        int status = postMapper.updateByPrimaryKeySelective(record);
        return status;
    }

    @Override
    public int updateByPrimaryKey(Post record) {
        int status = postMapper.updateByPrimaryKey(record);
        return status;
    }
}